package homework;

import java.util.Scanner;

public class CountSon {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("请输入字符串");
        String string1 = input.next();
        System.out.println("请输入子字符串");
        String string2 = input.next();
        int count = 0;
        int index = 0;
        while (index < string1.length()) {
            if (string1.indexOf(string2, index) == index) {
                count++;
            }
            index++;
        }
        System.out.println(string2 + "   在   " + string1 + " 中出现的次数为：" + count + " 次");
    }
}

